<template>
  <div class="caipu">
    <h1 class="biaoti">{{ title }}</h1>
    <!-- 请求数据1 -->
    <div v-show="this.obj">
      <div v-for="item in data2" class="cai ca1">
        <div class="leftcaiou" ref="box">
          <img :src="item.img" class="caiimg" />
          <div class="leftcaioubtm" ref="text">
            <p>综合评分：{{ item.username }}</p>
          </div>
        </div>

        <div class="leftcai" @click.stop="bumappao()">
          <a href="#">
            <div class="cainame" @click.stop="tiaozhuan" :data-titleid="item.id">{{ item.title }}</div>
          </a>
          <span class="bu">步骤图：</span>
          <span class="iconfont icon-shenpi buzouimg"></span>
          <div class="yuanliao">{{ item.yongliao }}</div>
          <span class="pingfen">综合评分：{{ item.id }}</span>
          <span class="madetime">({{ item["浏览次数"] }}做过)</span>
          <div class="zuozhe">{{ item.username }}</div>
        </div>
      </div>
    </div>
    <!-- 请求数据2 -->
    <div v-show="obj2">
      <div v-for="item in data3" class="cai ca2">
        <div class="leftcaiou" ref="box">
          <img :src="item.img" class="caiimg" />
          <div class="leftcaioubtm" ref="text">
            <p>综合评分：{{ item.username }}</p>
          </div>
        </div>

        <div class="leftcai">
          <div class="cainame">{{ item.title }}</div>
          <span class="bu">步骤图：</span>
          <span class="iconfont icon-shenpi buzouimg"></span>
          <div class="yuanliao">{{ item.yongliao }}</div>
          <span class="pingfen">综合评分：{{ item.id }}</span>
          <span class="madetime">({{ item["浏览次数"] }}做过)</span>
          <div class="zuozhe">{{ item.username }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "22菜谱",
      data2: "",
      data3: "",
    };
  },
  props: ["obj", "obj2"],
  methods: {
    bumappao() {},
    // 跳转
    tiaozhuan(e) {
      this.$router.push({
        path: `/menudetail/${e.target.dataset.titleid}`,
      });
    },
  },

  // 获取左边菜谱部分数据
  mounted() {
    console.log(this.obj);
    // 请求数据一
    this.$axios
      .get("/hxs/caidan", {
        params: { class1: "饼", class2: "烤箱" },
      })
      .then((res) => {
        console.log(res);
        this.data2 = res.data;
        // this.data3 = res.data;
      });
    // 请求数据二
    this.$axios
      .get("/hxs/caidan2", {
        params: { class1: "饼", class2: "烤箱" },
      })
      .then((res) => {
        console.log(res);
        this.data3 = res.data;
      });
  },
  components: {},
};
</script>


<style lang="scss" scoped>
.cai {
  display: flex;
  position: relative;
  width: 620px;
  margin-bottom: -47px;
}
.biaoti {
  margin-bottom: 13px;
  margin-left: 14px;
}
.leftcai {
  width: 400px;
  height: 230px;
  position: relative;
  margin-left: 14px;
}
.cainame {
  font-weight: bolder;
  font-size: 20px;
  margin-top: 10px;
}
.cainame:hover {
  color: red;
}
.yuanliao {
  width: 400px;
  height: 25px;
  margin-top: 8px;
  color: #ecb46c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.madetime {
  margin-left: 8px;
  margin-top: 18px;
  color: #adae90;
}
.zuozhe {
  margin-top: 18px;
  font-size: 18px;
  font-weight: bold;
  color: #adae90;
}
.leftcaiou {
  width: 230px;
  height: 150px;
  position: relative;
  // overflow: hidden;
}
.leftcaiou img {
  width: 100%;
  height: 100%;
}
.leftcaiou p {
  font-size: 18px;
  color: rgb(200, 255, 0);
  text-align: end;
  line-height: 220px;
}
.leftcaiou:hover .leftcaioubtm {
  display: block;
  top: 0;
}
.leftcaioubtm {
  width: 213px;
  height: 150px;
  background-color: rgb(190, 194, 126, 0.2);
  position: absolute;
  left: 0;
  top: 150px;
  display: none;
}
.buzouimg {
  display: inline-block;
  position: absolute;
  font-size: 27px;
  width: 40px;
  height: 30px;
  left: 383px;
  top: 11px;
  color: rgb(221, 175, 149);
}
.bu {
  position: absolute;
  top: 15px;
  left: 318px;
  font-size: 16px;
}
</style>
